<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fns.tld" prefix="fns" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <jsp:include page="/resources/inc/head.jsp" />
    <link href="${basePath}/resources/zheng-admin/plugins/zTree_v3/css/demo.css" rel="stylesheet"/>
    <link href="${basePath}/resources/zheng-admin/plugins/zTree_v3/css/metroStyle/metroStyle.css" rel="stylesheet"/>
</head>
<body>
<form class="layui-form layui-form-pane" id="_form">
    <input type="hidden" value="${meeting.id}" name="id"/>
    <div class="layui-form-item">
        <label class="layui-form-label">会议名称</label>
        <div class="layui-input-block">
            <input type="text" value="${meeting.meetingName}" name="meetingName" lay-verify="required"
                   autocomplete="off" placeholder="请输入会议名称"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">与会员工</label>
        <div class="layui-input-block ztreeDiv">
            <input type="text" readonly="readonly" lay-verify="required" id="usernames"
                   placeholder="请选择与会员工" class="layui-input" onclick="ZtreeCommon.showMenu(this)" ztreeId="ztree">
            <input type="hidden" value="${meeting.joinInfo}" name="joinInfo" id="userIds" ztreeId="ztree">
        </div>
        <div class="menuContent" style="display:none; position: absolute;z-index: 10000">
            <ul id="ztree" class="ztree" style="margin-top:0; width:220px;" value="${meeting.joinInfo}"></ul>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">会议开始时间</label>
        <div class="layui-input-block">
            <input type="text" name="beginTime" autocomplete="off"
                   placeholder="请选择会议开始时间"
                   value="<fmt:formatDate value='${meeting.beginTime}' pattern='yyyy-MM-dd HH:MM:ss'/>"
                   class="layui-input date-select" readonly="readonly">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">会议地点</label>
        <div class="layui-input-block">
            <input type="text" name="meetingPlace" value="${meeting.meetingPlace}" lay-verify="required"
                   autocomplete="off" placeholder="请输入会议地点"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="remark" autocomplete="off" placeholder="请输入备注"
                      class="layui-textarea">${meeting.remark}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block" style="float: right">
            <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
        </div>
    </div>
</form>
<jsp:include page="/resources/inc/pageFooter.jsp" />
<script src="${basePath}/resources/zheng-admin/js/my-ztree-common.js"></script>
<script>
    var meetingUsers = ${meetingUsers};
    var zNodes = getOrganizationTree(false, true);
    var tree = $.fn.zTree.init($("#ztree"), ZtreeCommon.checkBoxSetting, zNodes);
    $(meetingUsers).each(function (index, user) {
        var nodes = tree.getNodesByParam("id", user.userId, null);
        tree.checkNode(nodes[0], true);
    })
    $(function () {
        //日期的东西
        layui.use('laydate', function () {
            laydate = layui.laydate;
            $(".date-select").each(function (index, input) {
                laydate.render({
                    elem: this //指定元素
                    , theme: '#393D49'
                    , type: 'datetime'
                });
            });
        });
        //提交方法
        FormCommon.initForm({
            url: '${basePath}/oa/hr/meeting/update',
            subContentType: "json",
            editData: function (data) {
                data.beginTime = new Date(data.beginTime);
                return data;
            }
        });
        var checkeds = tree.getCheckedNodes();
        var names = [];
        $(checkeds).each(function (index, node) {
            names.push(node.name);
        });
        $("#usernames").val(names.join(","));
    });

</script>
</body>
</html>
